using System.Collections.Generic;
using Commons.Models.Settings.Matchers.Operators;
using Commons.Models.Stats;
using System;

namespace Commons.Models.Locks
{
	[Serializable]
	public class UserStatsUnlockCondition : UnlockCondition
	{
		private IDictionary<IStatUnit, int> requiredValues = new  Dictionary<IStatUnit, int>();
		private IDictionary<IStatUnit, int> requiredLevels = new  Dictionary<IStatUnit, int>();

		public IRelationalOperator<int> RelationalOperator { get; protected set; }

		public UserStatsUnlockCondition(IRelationalOperator<int> relationalOperator)
			: base("userStats")
		{
			this.RelationalOperator = relationalOperator;
		}

		public void AddRequiredValue(IStatUnit unit, int value)
		{
			requiredValues.Add(unit, value);
		}

		public void AddRequiredLevel(IStatUnit unit, int level)
		{
			requiredLevels.Add(unit, level);
		}

		public ICollection<IStatUnit> GetRequiredValuesUnits()
		{
			return requiredValues.Keys;
		}

		public ICollection<IStatUnit> GetRequiredLevelsUnits()
		{
			return requiredLevels.Keys;
		}

		public int GetRequiredValue(IStatUnit unit)
		{
			return requiredValues[unit];
		}

		public int GetRequiredLevel(IStatUnit unit)
		{
			return requiredLevels[unit];
		}

		public bool RequiresValue(IStatUnit unit)
		{
			return requiredValues.ContainsKey(unit);
		}

		public bool RequiresLevel(IStatUnit unit)
		{
			return requiredLevels.ContainsKey(unit);
		}
	}
}

